<!--<template>-->
<!--  <user-card-list :user-list="userList" />-->
<!--  <van-empty v-if="!userList || userList.length < 1" description="搜索结果为空" />-->
<!--</template>-->

<!--<script setup lang="ts">-->
<!--import {onMounted, ref} from 'vue';-->
<!--import {useRoute} from "vue-router";-->
<!--import myAxios from "../plugins/myAxios";-->
<!--import {Toast} from "vant";-->
<!--import qs from 'qs';-->
<!--import UserCardList from "../components/UserCardList.vue";-->

<!--const route = useRoute();-->
<!--const {tags} = route.query;-->

<!--const userList = ref([]);-->

<!--onMounted(async () => {-->
<!--  const userListData = await myAxios.get('/user/search/tags', {-->
<!--    params: {-->
<!--      tagNameList: tags-->
<!--    },-->
<!--    paramsSerializer: params => {-->
<!--      return qs.stringify(params, {indices: false})-->
<!--    }-->
<!--  })-->
<!--      .then(function (response) {-->
<!--        console.log('/user/search/tags succeed', response);-->
<!--        return response?.data;-->
<!--      })-->
<!--      .catch(function (error) {-->
<!--        console.error('/user/search/tags error', error);-->
<!--        Toast.fail('请求失败');-->
<!--      })-->
<!--  console.log(userListData)-->
<!--  if (userListData) {-->
<!--    userListData.forEach(user => {-->
<!--      if (user.tags) {-->
<!--        user.tags = JSON.parse(user.tags);-->
<!--      }-->
<!--    })-->
<!--    userList.value = userListData;-->
<!--  }-->
<!--})-->


<!--// const mockUser = {-->
<!--//   id: 12345,-->
<!--//   username: '鱼皮',-->
<!--//   userAccount: '12314',-->
<!--//   profile: '一名精神小伙，目前还有头发，谢谢大家，阿爸爸阿爸爸阿巴阿巴阿巴',-->
<!--//   avatarUrl: 'https://636f-codenav-8grj8px727565176-1256524210.tcb.qcloud.la/img/logo.png',-->
<!--//   gender: 0,-->
<!--//   phone: '13113113111',-->
<!--//   email: '592342843721987@xzcxzczxcz.com',-->
<!--//   userRole: 0,-->
<!--//   planetCode: '1234',-->
<!--//   tags: ['java', 'emo', '打工中', 'emo', '打工中'],-->
<!--//   createTime: new Date(),-->
<!--// }-->


<!--</script>-->

<!--<style scoped>-->

<!--</style>-->


<template>
  <user-card-list-by-tags :user-list="userList" />
  <van-empty v-if="!userList || userList.length < 1" description="搜索结果为空" />
</template>

<script setup >
import {onMounted, ref} from 'vue';
import {useRoute} from "vue-router";
import myAxios from "../plugins/myAxios";
import {Toast} from "vant";
import qs from 'qs';
const loading = ref(true);
import UserCardListByTags from "../components/UserCardListByTags.vue";

const route = useRoute();
const {tags} = route.query;

const userList = ref([]);

onMounted(async () => {
  const userListData = await myAxios.get('/user/search/tags', {
    params: {
      tagNameList: tags
    },
    paramsSerializer: params => {
      //原代码
      // return qs.stringify(params, {indices: false})
      return qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
      .then(function (response) {
        console.log('/user/search/tags succeed', response);
        return response?.data;
      })
      .catch(function (error) {
        console.error('/user/search/tags error', error);
        Toast.fail('请求失败');
      })
  console.log(userListData)
  if (userListData) {
    userListData.forEach(user => {
      if (user.tags) {
        user.tags = JSON.parse(user.tags);
      }
    })
    userList.value = userListData;
  }
  loading.value = false;
})

/*const mockUser = {
  id: 123456,
  username: 'aka',
  profile: '秋殇别恋11111111111111111111111',
  userAccount: 'sadas',
  avatarUrl: 'https://xingqiu-tuchuang-1256524210.cos.ap-shanghai.myqcloud.com/3925/202209032140505.jpg',
  gender: 0,
  phone: '11111111111',
  email: 'aaaa@qq.com',
  userRole: 0,
  planetCode: '12',
  tags: ['java', 'emo', '学习中'],
  createTime: new Date(),
}*/


</script>

<style scoped>

</style>

